package com.hmall.search.listener;

import com.hmall.common.constans.MqConstants;
import com.hmall.search.service.SearchService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MqListener {
    @Autowired
    private SearchService searchService;

    @RabbitListener(queues = MqConstants.ITEM_DELETE_QUEUE)
    public void itemDelete(Long id){
        searchService.deleteById(id);
    }

    @RabbitListener(queues = MqConstants.ITEM_INSERT_QUEUE)
    public void itemInsertAndUpdate(Long id){
        searchService.updateAndInsertById(id);
    }
}
